/*
* Copyright (C) 2006 Jordi Marquès Ferré
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this software; see the file DUROTY.txt.
*
* Author: Jordi Marquès Ferré
* c/Mallorca 295 principal B 08037 Barcelona Spain
* Phone: +34 625397324
*/


package com.duroty.hibernate;


// Generated 31-jul-2006 11:12:15 by Hibernate Tools 3.1.0.beta5
import java.util.Date;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;


/**
 * Message generated by hbm2java
 */
public class Message implements java.io.Serializable {
    // Fields    

    /**
     *
     */
    private static final long serialVersionUID = -6432676633601554946L;

    /**
     * DOCUMENT ME!
     */
    private int mesIdint;

    /**
     * DOCUMENT ME!
     */
    private Users users;

    /**
     * DOCUMENT ME!
     */
    private String mesName;

    /**
     * DOCUMENT ME!
     */
    private String mesReferences;

    /**
     * DOCUMENT ME!
     */
    private String mesBox;

    /**
     * DOCUMENT ME!
     */
    private String mesFrom;

    /**
     * DOCUMENT ME!
     */
    private String mesTo;

    /**
     * DOCUMENT ME!
     */
    private String mesCc;

    /**
     * DOCUMENT ME!
     */
    private String mesBcc;

    /**
     * DOCUMENT ME!
     */
    private String mesReplyTo;

    /**
     * DOCUMENT ME!
     */
    private String mesSubject;

    /**
     * DOCUMENT ME!
     */
    private String mesBody;

    /**
     * DOCUMENT ME!
     */
    private Date mesDate;

    /**
     * DOCUMENT ME!
     */
    private boolean mesFlagged;

    /**
     * DOCUMENT ME!
     */
    private boolean mesRecent;

    /**
     * DOCUMENT ME!
     */
    private int mesSize;

    /**
     * DOCUMENT ME!
     */
    private String mesHeaders;

    /**
     * DOCUMENT ME!
     */
    private Set attachments = new HashSet(0);

    /**
     * DOCUMENT ME!
     */
    private Set labMeses = new HashSet(0);

    // Constructors

    /** default constructor */
    public Message() {
    }

    /** minimal constructor */
    public Message(int mesIdint, Users users, String mesName, String mesBox,
        String mesFrom, String mesTo, String mesReplyTo, Date mesDate,
        boolean mesFlagged, boolean mesRecent, int mesSize) {
        this.mesIdint = mesIdint;
        this.users = users;
        this.mesName = mesName;
        this.mesBox = mesBox;
        this.mesFrom = mesFrom;
        this.mesTo = mesTo;
        this.mesReplyTo = mesReplyTo;
        this.mesDate = mesDate;
        this.mesFlagged = mesFlagged;
        this.mesRecent = mesRecent;
        this.mesSize = mesSize;
    }

    /** full constructor */
    public Message(int mesIdint, Users users, String mesName,
        String mesReferences, String mesBox, String mesFrom, String mesTo,
        String mesCc, String mesBcc, String mesReplyTo, String mesSubject,
        String mesBody, Date mesDate, boolean mesFlagged, boolean mesRecent,
        int mesSize, Set attachments, Set labMeses) {
        this.mesIdint = mesIdint;
        this.users = users;
        this.mesName = mesName;
        this.mesReferences = mesReferences;
        this.mesBox = mesBox;
        this.mesFrom = mesFrom;
        this.mesTo = mesTo;
        this.mesCc = mesCc;
        this.mesBcc = mesBcc;
        this.mesReplyTo = mesReplyTo;
        this.mesSubject = mesSubject;
        this.mesBody = mesBody;
        this.mesDate = mesDate;
        this.mesFlagged = mesFlagged;
        this.mesRecent = mesRecent;
        this.mesSize = mesSize;
        this.attachments = attachments;
        this.labMeses = labMeses;
    }

    // Property accessors

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public int getMesIdint() {
        return this.mesIdint;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesIdint DOCUMENT ME!
     */
    public void setMesIdint(int mesIdint) {
        this.mesIdint = mesIdint;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public Users getUsers() {
        return this.users;
    }

    /**
     * DOCUMENT ME!
     *
     * @param users DOCUMENT ME!
     */
    public void setUsers(Users users) {
        this.users = users;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesName() {
        return this.mesName;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesName DOCUMENT ME!
     */
    public void setMesName(String mesName) {
        this.mesName = mesName;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesReferences() {
        return this.mesReferences;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesReferences DOCUMENT ME!
     */
    public void setMesReferences(String mesReferences) {
        this.mesReferences = mesReferences;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesBox() {
        return this.mesBox;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesBox DOCUMENT ME!
     */
    public void setMesBox(String mesBox) {
        this.mesBox = mesBox;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesFrom() {
        return this.mesFrom;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesFrom DOCUMENT ME!
     */
    public void setMesFrom(String mesFrom) {
        this.mesFrom = mesFrom;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesTo() {
        return this.mesTo;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesTo DOCUMENT ME!
     */
    public void setMesTo(String mesTo) {
        this.mesTo = mesTo;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesCc() {
        return this.mesCc;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesCc DOCUMENT ME!
     */
    public void setMesCc(String mesCc) {
        this.mesCc = mesCc;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesBcc() {
        return this.mesBcc;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesBcc DOCUMENT ME!
     */
    public void setMesBcc(String mesBcc) {
        this.mesBcc = mesBcc;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesReplyTo() {
        return this.mesReplyTo;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesReplyTo DOCUMENT ME!
     */
    public void setMesReplyTo(String mesReplyTo) {
        this.mesReplyTo = mesReplyTo;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesSubject() {
        return this.mesSubject;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesSubject DOCUMENT ME!
     */
    public void setMesSubject(String mesSubject) {
        this.mesSubject = mesSubject;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesBody() {
        return this.mesBody;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesBody DOCUMENT ME!
     */
    public void setMesBody(String mesBody) {
        this.mesBody = mesBody;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public Date getMesDate() {
        return this.mesDate;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesDate DOCUMENT ME!
     */
    public void setMesDate(Date mesDate) {
        this.mesDate = mesDate;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public boolean isMesFlagged() {
        return this.mesFlagged;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesFlagged DOCUMENT ME!
     */
    public void setMesFlagged(boolean mesFlagged) {
        this.mesFlagged = mesFlagged;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public boolean isMesRecent() {
        return this.mesRecent;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesRecent DOCUMENT ME!
     */
    public void setMesRecent(boolean mesRecent) {
        this.mesRecent = mesRecent;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public int getMesSize() {
        return this.mesSize;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesSize DOCUMENT ME!
     */
    public void setMesSize(int mesSize) {
        this.mesSize = mesSize;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public Set getAttachments() {
        return this.attachments;
    }

    /**
     * DOCUMENT ME!
     *
     * @param attachments DOCUMENT ME!
     */
    public void setAttachments(Set attachments) {
        this.attachments = attachments;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public Set getLabMeses() {
        return this.labMeses;
    }

    /**
     * DOCUMENT ME!
     *
     * @param labMeses DOCUMENT ME!
     */
    public void setLabMeses(Set labMeses) {
        this.labMeses = labMeses;
    }

    /**
     * DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public String getMesHeaders() {
        return mesHeaders;
    }

    /**
     * DOCUMENT ME!
     *
     * @param mesHeaders DOCUMENT ME!
     */
    public void setMesHeaders(String mesHeaders) {
        this.mesHeaders = mesHeaders;
    }

    /**
     * DOCUMENT ME!
     *
     * @param attachment DOCUMENT ME!
     */
    public void addAttachment(Attachment attachment) {
        this.attachments.add(attachment);
    }

    /**
     * DOCUMENT ME!
     *
     * @param labMes DOCUMENT ME!
     */
    public void addLabMeses(LabMes labMes) {
        if (!containsLabMes(labMes)) {
            this.labMeses.add(labMes);
        }
    }

    /**
     * DOCUMENT ME!
     *
     * @param obj DOCUMENT ME!
     *
     * @return DOCUMENT ME!
     */
    public boolean containsLabMes(LabMes obj) {
        Iterator it = this.labMeses.iterator();

        while (it.hasNext()) {
            LabMes castObj = (LabMes) it.next();

            if ((castObj != null) && (obj != null) &&
                    (obj.getId().getLabel().getLabIdint() == castObj.getId()
                                                                        .getLabel()
                                                                        .getLabIdint())) {
                return true;
            }
        }

        return false;
    }
}
